package question

import "sort"

func numRescueBoats(people []int, limit int) int {
	ans := 0
	sort.Ints(people)
	start, end := 0, len(people)-1
	for start < end {
		if people[start]+people[end] > limit {
			end--
		} else {
			start++
			end--
		}
		ans++
	}
	return ans

}
